from ucolor import convert, ColorRGBA, ColorHSLA, ColorHSVA


# test to rgba
def test_hex_to_rgba() -> None:
    assert convert.hex_to_rgba("#FFFFFF") == ColorRGBA.white
    assert convert.hex_to_rgba("#FFF") == ColorRGBA.white
    assert convert.hex_to_rgba("#000000") == ColorRGBA.black
    assert convert.hex_to_rgba("#00FF00") == ColorRGBA.green
    assert convert.hex_to_rgba("#0F0") == ColorRGBA.green
    assert convert.hex_to_rgba("#212D09") == ColorRGBA(33, 45, 9)


def test_hsla_to_rgba() -> None:
    assert convert.hsla_to_rgba(ColorHSLA.white) == ColorRGBA.white
    assert convert.hsla_to_rgba(ColorHSLA.black) == ColorRGBA.black
    assert convert.hsla_to_rgba(ColorHSLA.green) == ColorRGBA.green
    assert convert.hsla_to_rgba(
        ColorHSLA(80, 60, 50)
    ) == ColorRGBA(153, 204, 51)


def test_hsva_to_rgba() -> None:
    assert convert.hsva_to_rgba(ColorHSVA.white) == ColorRGBA.white
    assert convert.hsva_to_rgba(ColorHSVA.black) == ColorRGBA.black
    assert convert.hsva_to_rgba(ColorHSVA.green) == ColorRGBA.green
    assert convert.hsva_to_rgba(
        ColorHSVA(80, 75, 80)
    ) == ColorRGBA(153, 204, 51)


# test to hsla
def test_rgba_to_hsla() -> None:
    assert convert.rgba_to_hsla(ColorRGBA.white) == ColorHSLA.white
    assert convert.rgba_to_hsla(ColorRGBA.black) == ColorHSLA.black
    assert convert.rgba_to_hsla(ColorRGBA.green) == ColorHSLA.green
    assert convert.rgba_to_hsla(
        ColorRGBA(153, 204, 51)
    ) == ColorHSLA(80, 60, 50)


def test_hex_to_hsla() -> None:
    assert convert.hex_to_hsla("#FFFFFF") == ColorHSLA.white
    assert convert.hex_to_hsla("#FFF") == ColorHSLA.white
    assert convert.hex_to_hsla("#000000") == ColorHSLA.black
    assert convert.hex_to_hsla("#00FF00") == ColorHSLA.green
    assert convert.hex_to_hsla(
        "#212D09"
    ) == ColorHSLA(80, 66.66666666666667, 10.588235294117647)


def test_hsva_to_hsla() -> None:
    assert convert.hsva_to_hsla(ColorHSVA.white) == ColorHSLA.white
    assert convert.hsva_to_hsla(ColorHSVA.black) == ColorHSLA.black
    assert convert.hsva_to_hsla(ColorHSVA.green) == ColorHSLA.green
    assert convert.hsva_to_hsla(
        ColorHSVA(80, 75, 80)
    ) == ColorHSLA(80, 60, 50)


# test to hsva
def test_rgba_to_hsva() -> None:
    assert convert.rgba_to_hsva(ColorRGBA.white) == ColorHSVA.white
    assert convert.rgba_to_hsva(ColorRGBA.black) == ColorHSVA.black
    assert convert.rgba_to_hsva(ColorRGBA.green) == ColorHSVA.green
    assert convert.rgba_to_hsva(
        ColorRGBA(153, 204, 51)
    ) == ColorHSVA(80, 75, 80)


def test_hex_to_hsva() -> None:
    assert convert.hex_to_hsva("#FFF") == ColorHSVA.white
    assert convert.hex_to_hsva("#000") == ColorHSVA.black
    assert convert.hex_to_hsva("#0F0") == ColorHSVA.green
    assert convert.hex_to_hsva(
        "#99CC33"
    ) == ColorHSVA(80, 75, 80)


def test_hsla_to_hsva() -> None:
    assert convert.hsla_to_hsva(ColorHSLA.white) == ColorHSVA.white
    assert convert.hsla_to_hsva(ColorHSLA.black) == ColorHSVA.black
    assert convert.hsla_to_hsva(ColorHSLA.green) == ColorHSVA.green
    assert convert.hsla_to_hsva(
        ColorHSLA(80, 60, 50)
    ) == ColorHSVA(80, 75, 80)


# test to hex
def test_rgba_to_hex() -> None:
    assert convert.rgba_to_hex(ColorRGBA.white) == "#FFF"
    assert convert.rgba_to_hex(ColorRGBA.white, force_long=True) == "#FFFFFF"
    assert convert.rgba_to_hex(ColorRGBA.black) == "#000"
    assert convert.rgba_to_hex(ColorRGBA.green) == "#0F0"
    assert convert.rgba_to_hex(ColorRGBA(33, 45, 9)) == "#212D09"


def test_hsla_to_hex() -> None:
    assert convert.hsla_to_hex(ColorHSLA.white) == "#FFF"
    assert convert.hsla_to_hex(ColorHSLA.white, force_long=True) == "#FFFFFF"
    assert convert.hsla_to_hex(ColorHSLA.black) == "#000"
    assert convert.hsla_to_hex(ColorHSLA.green) == "#0F0"
    assert convert.hsla_to_hex(ColorHSLA(80, 66.7, 10.6)) == "#212D09"


def test_hsva_to_hex() -> None:
    assert convert.hsva_to_hex(ColorHSVA.white) == "#FFF"
    assert convert.hsva_to_hex(ColorHSVA.white, force_long=True) == "#FFFFFF"
    assert convert.hsva_to_hex(ColorHSVA.black) == "#000"
    assert convert.hsva_to_hex(ColorHSVA.green) == "#0F0"


# test to ansi
def test_rgba_to_ansi() -> None:
    assert convert.rgba_to_ansi(ColorRGBA.white) == "\033[38;2;255;255;255m"
    assert convert.rgba_to_ansi(ColorRGBA.black) == "\033[38;2;0;0;0m"
    assert convert.rgba_to_ansi(ColorRGBA.green) == "\033[38;2;0;255;0m"
    assert convert.rgba_to_ansi(ColorRGBA(33, 45, 9)) == "\033[38;2;33;45;9m"


def test_hsla_to_ansi() -> None:
    assert convert.hsla_to_ansi(ColorHSLA.white) == "\033[38;2;255;255;255m"
    assert convert.hsla_to_ansi(ColorHSLA.black) == "\033[38;2;0;0;0m"
    assert convert.hsla_to_ansi(ColorHSLA.green) == "\033[38;2;0;255;0m"
    assert convert.hsla_to_ansi(
        ColorHSLA(80, 66.7, 10.6)
    ) == "\033[38;2;33;45;9m"


def test_hsva_to_ansi() -> None:
    assert convert.hsva_to_ansi(ColorHSVA.white) == "\033[38;2;255;255;255m"
    assert convert.hsva_to_ansi(ColorHSVA.black) == "\033[38;2;0;0;0m"
    assert convert.hsva_to_ansi(ColorHSVA.green) == "\033[38;2;0;255;0m"

